<template>
  <div>
    <div class="el-card" style="margin:20px 5%; padding: 5px">
      <van-card
          :title="this.info.name"
          thumb="https://img01.yzcdn.cn/vant/cat.jpeg"
      />
    </div>
    <van-notice-bar
        left-icon="volume-o"
        text="个人信息展示修改啦！！！！"
    />
    <div class="el-card" style="margin:20px 5%; padding: 5px">
      <span style="font-weight: bold;margin-left: 13px;margin-right: 65%">基本信息</span><van-icon name="edit" size="20px" @click="toupdate(info)"/>
      <van-cell title="姓名" :value="info.name" />
      <van-cell title="账号" :value="info.account" />
      <van-cell title="籍贯" :value="info.hometown" />
      <van-cell title="邮箱" :value="info.email" />
      <van-cell title="注册时间" :value="info.createTime" />
    </div>
    <van-button round block type="info" style="width: 90%;margin:20px 5%;" @click="logout()">退出登录</van-button>
  </div>
</template>

<script>
import {doGetStudent} from "@/api/student";

export default {
  name: "message",
  data(){
    return{
      info:{name:''},
    }
  },
  methods:{
    logout(){
      window.localStorage.removeItem("sid");
      this.$router.push('/');
    },
    getMsg(){
      doGetStudent(window.localStorage.getItem("sid")).then(res=>{
          if (res.code===200){
            this.info=res.data;
            console.log(this.info)
          }
      })
    },
    toupdate(student){
      this.$store.state.student=student;
      this.$router.push('/update')
    }
  },
  mounted() {
    this.getMsg();
  }
}
</script>

<style scoped>

</style>
